package com.project.JunM.controller;

import com.project.JunM.entity.SGather;
import com.project.JunM.service.SGatherService;
import com.project.common.entity.PageVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.Map;

@RestController
@RequestMapping("/SGather")
public class SGatherController {

    @Autowired
    private SGatherService sGatherService;

    //入库申请登记
    @PostMapping("/addSGather")
    public void addSGather(SGather sGather,String sGatherDetailsJsonObj) throws IOException {

        sGatherService.insertSelective(sGather,sGatherDetailsJsonObj);
    }
    //入库申请登记审核
    @PostMapping("/queryRegisterCheckAll.action")
    public PageVo<SGather> queryRegisterCheckAll(@RequestBody Map<String,String> map){

        PageVo<SGather> sGatherPageVo = sGatherService.queryRegisterCheckAll(map);

        return sGatherPageVo;
    }

    //入库申请查询
    @PostMapping("/queryRegisterSelectAll.action")
    public PageVo<SGather> queryRegisterSelectAll(@RequestBody Map<String,String> map){

        PageVo<SGather> sGatherPageVo = sGatherService.queryRegisterSelectAll(map);

        return sGatherPageVo;
    }

    //审核入库申请单
    @PostMapping("/updateSGatherByGatherId")
    public String updateSGatherByGatherId(SGather sGather){

        sGatherService.updateSGatherByGatherId(sGather);
        //返回一个审核标记
        String checkTag = sGather.getCheckTag();
        return checkTag;
    }

    @PostMapping("/queryPutSetAll.action")
    public PageVo<SGather> queryPutSetAll(@RequestBody Map<String,String> map){
        return sGatherService.queryPutSetAll(map);
    }

    @PostMapping("/queryPutCheckInAll.action")
    public PageVo<SGather> queryPutCheckInAll(@RequestBody Map<String,String> map){
        return sGatherService.queryPutCheckInAll(map);
    }

    /*入库查询*/
    @PostMapping("/queryPutCheckInSelectAll.action")
    public PageVo<SGather> queryPutCheckInSelectAll(@RequestBody Map<String,String> map){
        return sGatherService.queryPutCheckInSelectAll(map);
    }


    //入库登记复核
    @PostMapping("/updateStoreTagById")
    public void updateStoreTagById(Integer parentId,String checkTime){
        SGather sGather = new SGather();
        sGather.setId(parentId);
        sGather.setStoreTag("K002-3");
        sGather.setCheckTime(checkTime);
        sGatherService.updateByPrimaryKeySelective(sGather);
    }


    //入库登记复核查询
    @PostMapping("/queryPutCheckInAuditAll.action")
    public PageVo<SGather> queryPutCheckInAuditAll(@RequestBody Map<String,String> map){
        return sGatherService.queryPutCheckInAuditAll(map);
    }


}
